home *** CD-ROM | disk | FTP | other *** search
/ Hackers Handbook - Millenium Edition / Hackers Handbook.iso / library / hack / perliis.txt < prev    next >
Encoding:
Text File  |  1998-07-17  |  4.2 KB  |  111 lines

  1. [ from http://www.rootshell.com/ ]
  2.  
  3. From mnemonix@globalnet.co.uk Sun Jul 12 17:42:29 1998
  4. Date: Mon, 13 Jul 1998 01:31:11 +0100
  5. From: Mnemonix <mnemonix@globalnet.co.uk>
  6. To: info@rootshell.com
  7. Subject: New Perl.exe, IIS exploit 
  8.  
  9. Russ Cooper of ntbugtraq seems unwilling to publish this information -
  10. perhaps it shows how to exploit this too much:
  11.  
  12. ****************************************************************************
  13.  
  14. All versions of Internet Information Server seem to have a feature that can
  15. cause security problems when it has been configured to run Perl scripts to
  16. produce dynamic web pages, although really it is a combination of IIS and
  17. the Perl command interpreter (Perl.exe) acting together that can cause this
  18. hole. Basically the security implications of this problem is that data can
  19. be read from execute only virtual directories sometimes leading to the
  20. discovery of UserIDs and passwords.
  21.  
  22. Script extentions (in this case .cgi or .pl) are mapped against the
  23. interpreter in the registry under the following key:
  24.  
  25. HKLM\SYSTEM\CurrentControlSet\Services\W3SVC\Parameters\ScriptMap
  26.  
  27. When the web service receives a request from a browser it checks the
  28. extention of the file requested and deals with it accordingly. In this case
  29. if a .pl or .cgi file is requested IIS checks the registry to see what
  30. interpreter should deal with that kind of file and then passes the requested
  31. information to the interpreter, perl.exe. This is the "fault" of IIS : that
  32. it does not check to see whether the file actually exists or not; it just
  33. blindly passes the information to the interpreter. IIS leaves this
  34. responsibilty to the interpreter.
  35.  
  36. The second part of this problem is caused by the interpreter : perl.exe.
  37. Perl.exe will open and try to execute any file that actually exists as long
  38. as it has the extention .pl (if that is the registered extention.)
  39. Consequently if a space (%20) and .pl is appended to the end of a URL
  40. Internet Information Server will pass the request to perl.exe which will
  41. then open the file and try to execute it:
  42.  
  43. http://www.site.com/scripts/file.ext%20.pl
  44.  
  45. To demonstrate how this could be a problem : Some CGI scripts often require
  46. a .txt file that contains a userID and password such as wwwboard.cgi.
  47. Create a text file with two lines. On the first line type "Webadmin" and on
  48. the secondline type "Password". Like so:
  49.  
  50. Webadmin
  51. Password
  52.  
  53. And name the file pass.txt the request the following URL:
  54.  
  55. http://www.site.com/scripts/pass.txt%20.pl
  56.  
  57. You should receive a response similar to :
  58.  
  59. Can't call method "webadmin" in empty package "password" at
  60. C:\InetPub\scripts\pass.txt line 1
  61.  
  62. You can also glean information from other "sensitive" files such as .asp or
  63. .idc
  64.  
  65. http://www.site.com/scripts/default.asp%20.pl or
  66.  
  67. http://www.site.com/scripts/database.idc
  68.  
  69. You could even run old perl scripts that are still in the /scripts
  70. directory but have had their extention changed:
  71.  
  72. http://www.site.com/scripts/script.pl.old%20.pl
  73.  
  74.  
  75. This problem is exacerbated by the fact that perl.exe will accept willcards
  76. such as * and ? so you don't even need to know that name of a file. You can
  77. request :
  78.  
  79. http://www.site.com/scripts/*.txt%20.pl
  80.  
  81. and perl.exe will open the first text file in the scripts directory that it
  82. comes across. 
  83.  
  84. This was tested with Perl version 5.001 build 110. It is not yet known if
  85. other versions are affected. Testing would be appreciated.
  86.  
  87. Affected machines:
  88. NT Server 4.0 Service pack 1    IIS 2.0
  89. NT Server 4.0 Service pack 3    IIS 3.0
  90. NT Server 4.0 Service pack 3    IIS 4.0
  91. NT Wkst   4.0 Service pack 3    PWS 3.0
  92.  
  93. It is not yet know if other Web servers such as Netscape are affected.
  94. Again testing will prove if this is so and would be appreciated.
  95.  
  96. The solution to this problem is to use the ISAPI interpreter instead :
  97. PerlIS.dll. This leads to better performance anyway as the script is run in
  98. the same memory space as IIS and only one instance of it ever needs to be
  99. loaded into memory unlike perl.exe where for each script requested a new
  100. instance of perl.exe is loaded into its own memory space.
  101.  
  102. Mnemonix
  103. http://www.users.globalnet.co.uk/~mnemonix
  104.  
  105. ****************************************************************************
  106.  
  107. Thought you might be interested. Cheers.
  108. Mnemonix
  109. http://www.users.globalnet.co.uk/~mnemonix
  110.  
  111.